<?php
/**
 * Fang_DAO_Intro
 * 
 * 作者:  姚刚 (yaogang@the9sense.com)
 * 创建时间: 2011-03-14 21:01:50
 * 修改记录: 
 * 
 * $Id: Intro.php 18 2011-04-17 12:50:07Z coosuu $
 */

class Fang_DAO_Intro extends DAO_Mysql {

    const STATUS_NORMAL = 1;

    const STATUS_REMOVE = 9;

    private static $_table = 'fang_intro';

    /**
     * getRow 
     * 
     * @param  array $fields 
     * @return void
     */
    public static function getRow($fields = array()) {

        return parent::getRow(self::$_table, null, null, $fields);
    }

    /**
     * save 
     * 
     * @param  mixed $data 
     * @return void
     */
    public static function save($data) {

        if (self::getRow()) {

            if (!$data['i_updated']) {
                $data['i_updated'] = date('Y-m-d H:i:s');
            }

            $conditions = 'i_status = ?';
            $params = array(self::STATUS_NORMAL);
            return parent::update(self::$_table, $data, $conditions, $params);
        }

        if (!$data['i_created']) {
            $data['i_created'] = date('Y-m-d H:i:s');
        }

        if (!$data['i_status']) {
            $data['i_status'] = self::STATUS_NORMAL;
        }

        return parent::add(self::$_table, $data);
    }

}
